package com.meta.counter.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.meta.common.ConstDef;
import com.meta.counter.service.CounterService;
import com.meta.counter.dao.CounterDAO;

@Service
public class CounterServiceImpl implements CounterService {

	@Autowired
	private CounterDAO counterDAO;

	@Override
	public long nextTableId(){
		long counter =   counterDAO.nextCounter(ConstDef.COUNTER_TYPE_TABLE_ID);
		return counter;
	}

	@Override
	public long nextNegativeId(){
		long counter = -counterDAO.nextCounter(ConstDef.COUNTER_TYPE_NEGATIVE_ID);
		return counter;
	}
	
	
	@Override
	public String nextCounterStr( String type){
			long count = this.nextCounter(type);
			String code = String.format("%06d", count); 
			return code;
	}

	@Override
	public long nextCounter(String type) {
		
		return counterDAO.nextCounter(type);
	}

	

	@Override
	public long nextCounters(String type, int year, int size) {
	
			return counterDAO.nextCounters(type, year, size);
		
	}

}

